﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HP.Cachalote.DataModels;
using System.Data.Entity.ModelConfiguration;

namespace HP.Cachalote.Repositories.EntityFramework.Mappings
{
    public class TodoItemMap : EntityTypeConfiguration<TodoItem>
    {
        public TodoItemMap()
        {
            //Primary Key
            this.HasKey(t => t.ID);

            //Mapping
            this.ToTable("ToDoItems");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.LabelID).HasColumnName("LabelID");
            this.Property(t => t.Title).HasColumnName("Title");
            this.Property(t => t.Note).HasColumnName("Note");
            this.Property(t => t.IsDone).HasColumnName("IsDone");
            this.Property(t => t.Priority).HasColumnName("Priority");
            this.Property(t => t.DueDate).HasColumnName("DueDate");
            this.Property(t => t.StartTime).HasColumnName("StartTime");
            this.Property(t => t.EndTime).HasColumnName("EndTime");
            this.Property(t => t.NeedReminder).HasColumnName("NeedReminder");
            this.Property(t => t.IsDismissed).HasColumnName("IsDismissed");
            this.Property(t => t.ReminderTime).HasColumnName("ReminderTime");
            this.Property(t => t.CreateOn).HasColumnName("CreateOn");
            this.Property(t => t.UpdateOn).HasColumnName("UpdateOn");

            //Foreignkey
            this.HasOptional(t => t.Label)
                .WithMany(t => t.TodoItems)
                .HasForeignKey(t => t.LabelID);
        }
    }
}
